package com.ftg.learn.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ftg.learn.system.entity.Dept;
import com.ftg.learn.system.vo.RolePrivilegeVo;
import com.ftg.learn.util.JsonWeb;
import com.ftg.learn.util.JsonWebUtil;
import com.ftg.learn.util.page.PageCommUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 部门管理功能
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/5/9 下午3:13
 */
@Api(tags = "部门管理|部门管理")
@RequestMapping("/api/system/dept")
@RestController
public class DeptController {

    @Resource
    PageCommUtil<Dept> pageCommUtil;

    @GetMapping("/page")
    @ApiOperation("部门分页信息")
    public JsonWeb<IPage<Dept>> show(
        @ApiParam(value = "当前页数") @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @ApiParam(value = "每页显示条数") @RequestParam(value = "limit", defaultValue = "10") Integer limit
    ) {
        return JsonWebUtil.success(pageCommUtil.pageUtil("select * from sys_dept",pageNo,limit));
    }

//
//    @GetMapping("/page1")
//    @ApiOperation("部门分页信息条件")
//    public JsonWeb<IPage<RolePrivilegeVo>> show1(
//            @ApiParam(value = "当前页数") @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
//            @ApiParam(value = "每页显示条数") @RequestParam(value = "limit", defaultValue = "10") Integer limit
//    ) {
//        QueryWrapper<RolePrivilegeVo> q = new QueryWrapper<>();
//        q.like("dept_name","1");
//        return JsonWebUtil.success(pageCommUtil.pageUtil1("select * from sys_dept",q,pageNo,limit));
//    }
}
